<?php echo $javascript->link('/eav/js/eav.js',false)?>

<script type="text/javascript">
	var typeOptions =  <?php echo $javascript->object(ClassRegistry::getObject($fieldModelAlias)->getOptionsFieldType())?>;
	Eav.modelAlias = "<?php echo $fieldModelAlias?>";
	$(document).ready(function()
	{
		$("#CustomFieldOptions").parent().sortable({"items":'.fieldWrap'});
		Eav.doForFieldType_old = Eav.doForFieldType;
		Eav.checkfForUrlMaksing = function()
		{
			if($('#'+this.getFieldId('Type')).val() == "url")
			{
				$('#CustomFieldMaskUrl').parent().show();
				$('#CustomFieldAnchorText').parent().show();
			}else
			{
				$('#CustomFieldMaskUrl').parent().hide();
				$('#CustomFieldAnchorText').parent().hide();
			}
		}
		Eav.doForFieldType = function()
		{
    		this.doForFieldType_old();
    		this.checkfForUrlMaksing();
		}
		Eav.typeWithOptions = $.makeArray(typeOptions);
		
		$('#'+Eav.getFieldId('Type')).change(function(){
				Eav.doForFieldType();
			})
		var html = $('#CustomFieldMaskUrl').parent().outerHTML();
		var anchorHtml = $('#CustomFieldAnchorText').parent().outerHTML();
		$('#CustomFieldMaskUrl').parent().remove();
		$('#CustomFieldAnchorText').parent().remove();
		$('#'+Eav.getFieldId('Type')).parent().after(html).after(anchorHtml);
		Eav.doForFieldType();
	});
</script>